import{AxiosHeaders as e,AxiosError as o}from"axios";import s from"../../node_modules/.pnpm/axios@1.13.2/node_modules/axios/lib/core/settle.mjs";import{resolveUniAppRequestOptions as n,progressEventReducer as t}from"../utils/index.mjs";import r from"./onCanceled.mjs";const i=i=>new Promise((d,a)=>{const l=n(i),u=i;u.headers=new e(l.header);const c=new r(i);let m=uni.downloadFile({...l,success(e){if(!m)return;const o={config:u,data:e.tempFilePath,headers:{},status:e.statusCode,statusText:e.errMsg??"OK",request:m};s(d,a,o),m=null},fail(e){const{errMsg:s=""}=e??{};if(s){"downloadFile:fail timeout"===s&&a(new o(s,o.ETIMEDOUT,u,m));("downloadFile:fail"===s||"downloadFile:fail "===s)&&a(new o(s,o.ERR_NETWORK,u,m))}a(new o(e.errMsg,void 0,u,m)),m=null},complete(){c.unsubscribe()}});"function"==typeof i.onDownloadProgress&&m.onProgressUpdate(t(i.onDownloadProgress,!0)),"function"==typeof i.onHeadersReceived&&m.onHeadersReceived(i.onHeadersReceived),c.subscribe(m,a)});export{i as default};
//# sourceMappingURL=download.mjs.map
